module.exports = {
  webpack: {
    configure(webpackConfig) {
      if (webpackConfig.mode == "production") {
        //抽离公共代码只在生成环境
        if (webpackConfig.optimization == null) {
          webpackConfig.optimization = {};
        }
        webpackConfig.optimization.splitChunks = {
          chunks: "all", //对所有包进行优化
          cacheGroups: {
            antd: {
              name: "antd-chunk",
              test: /antd/,
              priority: 100,
            },
            reactDom: {
              name: "reactDom-chunk",
              test: /react-dom/,
              priority: 99,
            },
            //其他供应商
            vendors: {
              name: "vendors-chunk",
              test: /node_modules/,
              priority: 98,
            },
          },
        };
      }
      return webpackConfig;
    },
  },
  devServer: {
    port: 8000,
    proxy: {
      "/api": "http://localhost:3001",
    },
  },
};
